#helpful script to deploy plugin to docker container

# read -p "Enter container ID or name: "  container
#read -p "Enter working subdirectory /usr/local/share/lua/5.1/kong/plugins/"  dir
container="kong-gateway"
#container="kong-demo"
dir="header-mq" 

docker exec -it --user kong $container mkdir /usr/local/share/lua/5.1/kong/plugins/$dir
echo "directory created or verified"
docker cp plugin/. $container:/usr/local/share/lua/5.1/kong/plugins/$dir
docker cp . $container:/usr/local/share/lua/5.1/kong/plugins/$dir/src
echo "contents copied to /usr/local/share/lua/5.1/kong/plugins/$dir"
docker exec --user kong -e KONG_PLUGINS="bundled,$dir" $container kong reload -vv
echo "Kong restarted with $dir plugin enabled"
